package Code.Test;

import java.util.ArrayList;
import java.util.Scanner;

public class S2 {
    public static void main(String[] args) {
        //创建集合
        ArrayList<Student> list = new ArrayList<>();

        //键盘录入学生的信息，并且添加到集合当中
        Scanner scanner = new Scanner(System.in);
        for (int i = 0; i < 3; i++) {
            Student s = new Student();
            System.out.println("请输入学生的姓名:");
            s.setName(scanner.next());
            System.out.println("请输入学生的年龄：");
            s.setAge(scanner.nextInt());
            list.add(s);
        }


        for (int i = 0; i < list.size(); i++) {
            Student stu = list.get(i);
            System.out.println(stu.getName()+"   "+stu.getAge());
        }
    }
}
